package com.lm.controller;

import com.lm.pojo.Menu;
import com.lm.service.MenuService;
import com.lm.util.ResultUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @version 1.0
 * @dscription:TODO
 * @author32477
 * @date 2025/9/26 15:48
 */
@CrossOrigin
@Api(tags = "菜单管理")
@RestController
@RequestMapping("/menu")
public class MenuController {
    @Autowired
    private MenuService menuService;

    /**
     * @description:TODO 获取菜单列表
     * @author:LM
     * @date:2025/9/26 15:49
     * @param:roleId
     * @return:com.lm.util.ResultUtil<java.util.List<com.lm.pojo.Menu>>
     */
    @ApiOperation(value="获取菜单列表", notes = "获取菜单列表",httpMethod = "GET")
    @GetMapping("/getMenu")
    public ResultUtil<List<Menu>>getList(Integer roleId){
        try{
            List<Menu> list = menuService.getList(roleId);
            return new ResultUtil<>(200,"查询成功",list);
        }catch (Exception e){
            e.printStackTrace();
            return new ResultUtil<>(500,"查询失败");
        }

    }
}
